package com.zj.study;

public class m个苹果放入n个盘子 {

    public static void main(String[] args) {
        System.out.println(getres(7, 4));
    }

    public static int getres(int m, int n) {
        int maxc = 0;
        int[][] arr = new int[m + 1][n + 1];
        for (int i = 0; i < m + 1; i++) {
            for (int j = 1; j < n + 1; j++) {
                if (i == 0 || i == 1 || j == 1) {
                    arr[i][j] = 1;
                } else {
                    arr[i][j] = i < j ? arr[i][j - 1] : arr[i][j - 1] + arr[i - j][j];
//                    arr[i][j]+=arr[i][j-1];
//                    for(int k=1;k<=i/j;k++){
//                        arr[i][j]+=arr[i-k*j][j-1];
//                    }
                }
            }
        }
        for (int i = 0; i < m + 1; i++) {
            for (int j = 0; j < n + 1; j++) {
                System.out.print(arr[i][j] + " ");
            }
            System.out.println();
        }
        return arr[m][n];
    }
}
